function sendPrompt() {
    const prompt = document.getElementById('prompt').value;
    const responseElement = document.getElementById('response');

    fetch('/chat', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({prompt: prompt})
    })
        .then(response => response.json())
        .then(data => {
            responseElement.textContent = data;
        })
        .catch(error => {
            console.error('Error:', error);
            responseElement.textContent = 'An error occurred while processing your request.';
        });
}